import 'package:dio/dio.dart';
import 'package:flutterlib/common/datacenter/user_center.dart';
import 'package:flutterlib/common/constants/constants.dart';
import 'package:thrio/thrio.dart';
/**
 * header拦截器
 * Created by guoshuyu
 * on 2019/3/23.
 */
class HeaderInterceptors extends InterceptorsWrapper {
  @override
  onRequest(RequestOptions options) async {
    ///超时
    options.connectTimeout = 15000;

    if(currentUser != null){
      options.headers["uid"] = currentUserId;
      options.headers["authme"] = currentUser.token;
    }else{
      options.headers["uid"] = 0;
      options.headers["authme"] = '';
    }
    // var authorization =
    // trueDebugPrint("flutterting authorization" + authorization.toString());
    options.headers["Authorization"] = await ChannelDataCenter().invoke("getAuthorization");

    return options;
  }
}
